

public class Test {
    public static void main(String[] args) {
//        Computer computer = new Computer();
//        System.out.println("==============");
//        System.out.println(computer.toString());
//        System.out.println("==============");
//        computer.open();
//        System.out.println("==============");
//        computer.close();

//        Mijia mijia = new Mijia();
//        System.out.println(mijia.toString());
//        System.out.println("===============");
//        Mijia mijia1 = new Mijia();
//        mijia1.xiaoai();
//        mijia1.open();
//        System.out.println("===============");
//        mijia1.xiaoai();
//        mijia.close();

        Computer a0 = new Computer();
        System.out.println("===========");
        Computer a2 = new Mijia();
        System.out.println("===========");
        Computer a1 = new Xiaomi();

    }
}

class Computer {    //类
    //普通成员变量
     public String name;
     public int edition;
     public String color;
     //静态成员变量
    static String all_name;
    //实例代码块
    {
        System.out.println("父类 实例代码块执行");
    }
    //静态代码块
    static{
        Computer.all_name = "计算机";
        System.out.println("父类 静态代码块执行");
    }
    public Computer(){
        this("xiaomi",15,"grey");
        System.out.println("父类 构造方法执行");
    }
     //构造方法
     public Computer(String name,int edititon,String color){
         this.name = name;
         this.edition = edititon;
         this.color = color;
     }

    @Override
    public String toString() {
        return "Computer{" +
                "name='" + name + '\'' +
                ", edition=" + edition +
                ", color='" + color + '\'' +
                '}';
    }

    //成员方法
     public void open() {
        System.out.println(name + "开启电脑");
    }
    public void close() {
        System.out.println(name + "关闭电脑");
    }
}

class Mijia extends Computer{
    static{
        System.out.println("子类 静态代码块执行");
    }
    {
        System.out.println("子类 实例代码块执行");
    }
    public Mijia(){
        System.out.println("子类 构造方法执行");
    }
    public void xiaoai() {
        System.out.println("小爱同学");
    }
}

class Xiaomi extends Mijia{
    static{
        System.out.println("Xiaomi 静态代码块执行");
    }
    {
        System.out.println("Xiaomi 实例代码块执行");
    }
    Xiaomi(){
        System.out.println("Xiaomi 构造方法执行");
    }
}

class Base {
    Base() {
        System.out.print("Base");
    }
}

class Alpha extends Base {

    public static void main( String[] args ) {
        new Alpha();//1
        //调用父类无参的构造方法
        new Base();//2
    }
}
